<template>
  <div>
    <!--  -->
    <crumbs @goBack="goBack" :superiorMenu="['库存管理']" currentMenu="库存调拨"></crumbs>
    <a-card :bordered="false" style="height: 100%; margin-top: 12px">
      <a-button @click="handleShowFilter" icon="filter"
        >筛选 <span class="filter-num" style="margin-left: 5px">{{ ' ' + filteredNums }}</span></a-button
      >
      <a-button @click="showColumn" icon="unordered-list" class="btns">设置列</a-button>
      <div class="right-btn">
        <a-button @click="add" type="primary" class="btns"> +新建 </a-button>
      </div>
      <a-table
        size="middle"
        :key="tableKey"
        :scroll="{ x: scrollX, y: 'calc(100vh - 366px)' }"
        :columns="columns"
        :dataSource="modelList"
        :pagination="false"
        class="j-table-force-nowrap"
        @change="handleChange"
        :components="drag(columns, 'STOCKALLOCATION_LIST')"
      >
        <span slot="actions" slot-scope="text, record">
          <div style="width: 100%; height: 100%; background: #fff"></div>
          <span v-if="record.flowStatus == 'RUNNING' && record.createBy == loginUser">
            <a @click="handleWithdraw(record)">撤回</a>
            <!-- <a-divider type="vertical" /> -->
            <!-- <a  @click="handleDetail(record)">详情</a> -->
          </span>
          <span v-else>
            <!-- <a @click="handleDetail(record)">详情</a> -->
          </span>
        </span>
        <!-- 行信息 -->
        <span slot="allotOrder" :title="record.allotOrder" slot-scope="text, record">
          <!-- {{ record.applyNumber }} -->
          <a @click="handleDetail(record)">{{ record.allotOrder }}</a>
        </span>
        <span slot="outWarehouseId" :title="record.outWarehouseId" slot-scope="text, record">
          {{ record.outWarehouseName || '-' }}
        </span>
        <span slot="inWarehouseId" :title="record.inWarehouseId" slot-scope="text, record">
          {{ record.inWarehouseName || '-' }}
        </span>
        <span slot="qualifiedNum" :title="record.qualifiedNumText" slot-scope="text, record">
          {{ record.qualifiedNumText || '-' }}
        </span>
        <span slot="scrapNum" :title="record.scrapNumText" slot-scope="text, record">
          {{ record.scrapNumText || '-' }}
        </span>
        <span slot="goodsCode" :title="record.goodsCode" slot-scope="text, record">
          {{ record.goodsCode || '-' }}
        </span>
        <span slot="goodsName" :title="record.goodsName" slot-scope="text, record">
          {{ record.goodsName || '-' }}
        </span>
        <span slot="allotTime" :title="record.allotTime" slot-scope="text, record">
          {{ record.allotTime || '-' }}
        </span>
        <span slot="createBy" :title="record.createBy" slot-scope="text, record">
          {{ record.createBy || '-' }}
        </span>
        <span slot="createTime" :title="record.createTime" slot-scope="text, record">
          {{ record.createTime || '-' }}
        </span>
        <span slot="orderStatus" :title="record.orderStatus" slot-scope="text, record">
          {{ record.orderStatus == 'take_effect' ? '已生效' : '未生效' }}
        </span>
        <span slot="flowStatus" :title="record.flowStatus" slot-scope="text, record">
          {{ record.flowStatusTxt || '-' }}
        </span>
        <span slot="status" :title="record.statusTxt" slot-scope="text, record">
          {{ record.statusTxt || '-' }}
        </span>
        <!-- 6个字符控制 超出。。。 -->
        <!-- <span :title="text" slot="spec" slot-scope="text">
          {{ text }}
        </span> -->
        <!-- 输入框搜索 -->
        <div slot="searchInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOreder">
          <a-input
            placeholder="请输入"
            v-model="filterForm[column.dataIndex]"
            style="width: 188px; display: block"
            @pressEnter="handleSearch"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="searchIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 选择搜索 -->
        <div slot="selectDropdown" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select
            mode="multiple"
            placeholder="请选择"
            allowClear
            style="width: 188px"
            v-model="filterForm[selectkeys(column.dataIndex)]"
          >
            <a-select-option v-for="(item, i) in flowStatusList" :key="i" :value="item.value">{{
              item.text
            }}</a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="selectIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 选择搜索-调拨 -->
        <div slot="selectDropdownAllot" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select
            mode="multiple"
            placeholder="请选择"
            allowClear
            style="width: 188px"
            v-model="filterForm[selectkeys(column.dataIndex)]"
          >
            <a-select-option v-for="(item, i) in allocationStatus" :key="i" :value="item.value">{{
              item.text
            }}</a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="selectIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 选择搜索 -->
        <div slot="selectDropdown1" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select
            mode="multiple"
            :placeholder="checkPlaceholder(column.dataIndex)"
            allowClear
            style="width: 188px"
            v-model="filterForm[column.dataIndex]"
          >
            <a-select-option v-for="(item, key) in warehouseList" :key="key" :value="item.id">
              {{ item.warehouseName }}
            </a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="selectIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 日期搜索 -->
        <!-- <div slot="datePicker" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-range-picker
            style="width: 188px"
            v-model="filterForm[column.dataIndex]"
            date-format="YYYY-MM-DD"
            @change="rangePickChang"
            :placeholder="['开始时间', '结束时间']"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="dateIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        /> -->
        <!-- 日期搜索 -->
        <!-- <div slot="datePicker2" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-range-picker
            style="width: 188px"
            v-model="filterForm[column.dataIndex]"
            date-format="YYYY-MM-DD"
            @change="rangePickChang2"
            :placeholder="['开始时间', '结束时间']"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="dateIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        /> -->
        <!-- 日期搜索 -->
        <div slot="datePicker" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-range-picker
            style="width: 188px"
            v-model="dateForm[column.dataIndex]"
            format="YYYY-MM-DD"
            :placeholder="['开始时间', '结束时间']"
            @change="(v) => onOk(v, column.dataIndex)"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="dateIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 提交日期搜索 -->
        <div slot="datePicker2" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-range-picker
            style="width: 188px"
            v-model="dateForm[column.dataIndex]"
            format="YYYY-MM-DD"
            :placeholder="['开始时间', '结束时间']"
            @change="(v) => onOkCreate(v, column.dataIndex)"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="dateIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 选择搜索 -->
        <div slot="selectDropdown2" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select
            mode="multiple"
            :placeholder="checkPlaceholder(column.dataIndex)"
            allowClear
            style="width: 188px"
            v-model="filterForm[column.dataIndex]"
          >
            <a-select-option value="1">未开始</a-select-option>
            <a-select-option value="2">进行中</a-select-option>
            <a-select-option value="3">已完成</a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <!-- 选择搜索 -->
        <!-- <div slot="selectDropdown3" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select
            mode="multiple"
            :placeholder="checkPlaceholder(column.dataIndex)"
            allowClear
            style="width: 188px"
            v-model="filterForm[column.dataIndex]"
          >
            <a-select-option value="1">未开始</a-select-option>
            <a-select-option value="2">进行中</a-select-option>
            <a-select-option value="3">已完成</a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div> -->
        <!-- 选择搜索 -->
        <div slot="selectDropdown3" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select
            mode="multiple"
            :placeholder="checkPlaceholder(column.dataIndex)"
            allowClear
            style="width: 188px"
            v-model="filterForm[column.dataIndex]"
          >
            <a-select-option value="effective">已生效</a-select-option>
            <a-select-option value="no_effective">未生效</a-select-option>
          </a-select>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
      </a-table>
      <SetColumn
        columnName="设置列"
        ref="SetColumn"
        v-if="showSetColumn"
        @sureBtn="sureBtn"
        @cancelBtn="showSetColumn = false"
      />
    </a-card>
    <a-drawer placement="right" width="500" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">
          筛选 <span class="filter-num">{{ filteredNums }}</span>
        </div>
        <div class="uni-card" v-if="filteredNums > 0" style="background: #fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="item.text" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float: right" />
            </span>
          </div>
        </div>
        <div style="overflow-y: scroll; flex: 1; padding: 0">
          <div class="uni-card" style="background: #fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="调拨单号">
                <a-input v-model="filterForm.allotOrder" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="调出仓库">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.outWarehouseId">
                  <a-select-option v-for="(item, key) in warehouseList" :key="key" :value="item.id">
                    <span :title="item.warehouseName || item.id">
                      {{ item.warehouseName || item.id }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-model-item>
              <a-form-model-item label="调入仓库">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.inWarehouseId">
                  <a-select-option v-for="(item, key) in warehouseList" :key="key" :value="item.id">
                    <span :title="item.warehouseName || item.id">
                      {{ item.warehouseName || item.id }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-model-item>
              <a-form-model-item label="调拨物品编号">
                <a-input v-model="filterForm.goodsCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="调拨物品名称">
                <a-input v-model="filterForm.goodsName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="规格">
                <a-input v-model="filterForm.spec" placeholder="请输入" />
              </a-form-model-item>

              <!-- <a-form-model-item label="调拨日期">
                <a-range-picker
                  date-format="YYYY-MM-DD"
                  :placeholder="['请选择', '请选择']"
                  v-model="filterForm.planStartTime"
                  style="width: 100%"
                  @change="startTimeChange"
                />
              </a-form-model-item> -->

              <a-form-model-item label="调拨日期">
                <a-range-picker
                  style="width: 100%"
                  v-model="dateForm['allotTime']"
                  format="YYYY-MM-DD"
                  :placeholder="['开始时间', '结束时间']"
                  @change="(v) => onOk(v, 'allotTime')"
                />
              </a-form-model-item>

              <a-form-model-item label="调拨人">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.inWarehouseId">
                  <a-select-option v-for="(item, key) in warehouseList" :key="key" :value="item.id">
                    <span :title="item.warehouseName || item.id">
                      {{ item.warehouseName || item.id }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-model-item>
              <!-- <a-form-model-item label="调拨单提交日期">
                <a-range-picker
                  date-format="YYYY-MM-DD"
                  :placeholder="['请选择', '请选择']"
                  v-model="filterForm.planStartTime2"
                  style="width: 100%"
                  @change="startTimeChange2"
                />
              </a-form-model-item> -->
              <a-form-model-item label="调拨单提交日期">
                <a-range-picker
                  style="width: 100%"
                  v-model="dateForm['createTime']"
                  format="YYYY-MM-DD"
                  :placeholder="['开始时间', '结束时间']"
                  @change="(v) => onOkCreate(v, 'createTime')"
                />
              </a-form-model-item>
              <!--  -->
              <!-- <a-form-model-item label="仓库编号">
                <a-input v-model="filterForm.applyNumber" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="仓库名称">
                <a-input v-model="filterForm.warehouseName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="分类">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.warehouseType">
                  <a-select-option v-for="(item, key) in dictOptions" :key="key" :value="item.value">
                    <span :title="item.text || item.label">
                      {{ item.text || item.label }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-model-item> -->
              <a-form-model-item label="审核状态">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.flowStatus">
                  <a-select-option v-for="(item, key) in flowStatusList" :key="key" :value="item.value">
                    <span :title="item.text || item.label">
                      {{ item.text || item.label }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-model-item>
              <a-form-model-item label="调拨状态">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.orderStatus">
                  <a-select-option v-for="(item, key) in allocationStatus" :key="key" :value="item.value">
                    <span :title="item.text || item.label">
                      {{ item.text || item.label }}
                    </span>
                  </a-select-option>
                </a-select>
              </a-form-model-item>
              <!-- <a-form-model-item label="仓库状态">
                <a-select allowClear mode="multiple" placeholder="请选择" v-model="filterForm.status">
                  <a-select-option value="effective">已生效</a-select-option>
                  <a-select-option value="no_effective">未生效</a-select-option>
                </a-select>
              </a-form-model-item> -->
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <!-- 全选/分页 -->
    <div
      class="uni-card"
      :style="{ position: 'fixed', bottom: 0, right: 0, left: collapsed ? '79px' : '208px', background: '#fff' }"
    >
      <div style="display: inline-block">
        <span>
          {{ `共 ${total} 条` }}
        </span>
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination
          :total="total"
          v-model="current"
          :page-size-options="pageSizeOptions"
          :page-size="pageSize"
          @change="onChangePage"
          @showSizeChange="onShowSizeChange"
          show-quick-jumper
          show-size-changer
        />
      </div>
    </div>
    <!-- 新增仓库||编辑 弹框 -->
    <!-- <a-modal
      v-model="addDialog"
      width="55%"
      :bodyStyle="{ padding: '32px 32px 24px', boxSizing: 'border-box' }"
      :maskClosable="false"
      :title="clickType == 'newAdd' ? '新增仓库' : '编辑'"
      @cancel="cancelAdd"
    >
      <a-form-model ref="addForm" :model="newAddForm" :rules="addRules" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-form-model-item label="编号：" prop="applyNumber">
          <a-input
            v-model="newAddForm.applyNumber"
            placeholder="请输入"
            :maxLength="14"
            @blur="checkInputValue(newAddForm.applyNumber)"
          />
          <span class="btn-text code-btn" @click="genEntityCode" v-if="!isEdit">自动生成</span>
        </a-form-model-item>
        <a-form-model-item label="仓库名称：" prop="warehouseName">
          <a-input v-model="newAddForm.warehouseName" placeholder="请输入" />
        </a-form-model-item>
        <a-form-model-item label="仓库分类：" prop="warehouseType">
          <a-select placeholder="请选择" v-model="newAddForm.warehouseType" @change="typeSelectChange">
            <a-select-option :value="undefined">请选择</a-select-option>
            <a-select-option v-for="(item, key) in dictOptions" :key="key" :value="item.value">
              <span :title="item.text || item.label">
                {{ item.text || item.label }}
              </span>
            </a-select-option>
          </a-select>
        </a-form-model-item>
      </a-form-model>
      <div v-if="addDialog">
        <Examine
          @submitProcess="submitProcess"
          v-if="clickType == 'newAdd'"
          type="0"
          id="WMS_WAREHOUSE"
          ref="examine"
        />
      </div>
      <template slot="footer">
        <a-button @click="cancelAdd">取消</a-button>
        <a-button type="primary" :loading="accloading" @click="submitProcess">确定</a-button>
      </template>
    </a-modal> -->
    <windowForm ref="windowForm" @refresh="handleSearch"></windowForm>
    <windowDetail ref="windowDetail"></windowDetail>
  </div>
</template>
<script>
import SetColumn from '@/pubComponent/SetColumn.vue'
import crumbs from '@/components/crumbs.vue'
import { getNewColumns, subStrText, camelCase2UnderLine, validateDuplicateValue } from '@/utils/util'
import { API } from '@/api/requestFzs'
import { APILX } from '@/api/requestLx'
import moment from 'dayjs'
import { mapState } from 'vuex'
import { returnMaterialApplyList, getDictModel } from '@/api/goodsManagement'
import Examine from '@/components/examine'
import { getEnableOne } from '@/api/api'
import { stockAllocationListApi, stockAllocQueryWarehouse, queryGoodApi } from '@/api/erpApi'
import tableDragResize from '@/mixins/tableDragResize'
// 表头
const columnsValue = [
  {
    title: '调拨单号',
    ellipsis: true,
    dataIndex: 'allotOrder',
    width: 180,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'allotOrder',
    },
  },
  {
    title: '调出仓库',
    ellipsis: true,
    dataIndex: 'outWarehouseId',
    width: 180,
    scopedSlots: {
      filterDropdown: 'selectDropdown1',
      filterIcon: 'selectIcon',
      customRender: 'outWarehouseId',
    },
  },
  {
    title: '调入仓库',
    ellipsis: true,
    dataIndex: 'inWarehouseId',
    width: 150,
    scopedSlots: {
      filterDropdown: 'selectDropdown1',
      filterIcon: 'selectIcon',
      customRender: 'inWarehouseId',
    },
  },
  {
    title: '调拨合格品数',
    align: 'left',
    width: 150,
    ellipsis: true,
    dataIndex: 'qualifiedNum',
    scopedSlots: {
      customRender: 'qualifiedNum',
    },
  },
  {
    title: '调拨报废品数',
    align: 'left',
    width: 150,
    ellipsis: true,
    dataIndex: 'scrapNum',
    scopedSlots: {
      customRender: 'scrapNum',
    },
  },
  {
    title: '调拨合格品数(F)',
    align: 'left',
    width: 150,
    ellipsis: true,
    dataIndex: 'qualifiedNumTextAssistUnit',
  },
  {
    title: '调拨报废品数(F)',
    align: 'left',
    width: 150,
    ellipsis: true,
    dataIndex: 'scrapNumTextAssistUnit',
  },
  {
    title: '调拨物品编号',
    ellipsis: true,
    dataIndex: 'goodsCode',
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'goodsCode',
    },
  },
  {
    title: '调拨物品名称',
    ellipsis: true,
    dataIndex: 'goodsName',
    width: 180,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'goodsName',
    },
  },
  {
    title: '规格',
    ellipsis: true,
    dataIndex: 'spec',
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      // customRender: 'spec',
    },
  },
  {
    title: '调拨日期',
    ellipsis: true,
    dataIndex: 'allotTime',
    width: 180,
    scopedSlots: {
      filterDropdown: 'datePicker',
      filterIcon: 'dateIcon',
      customRender: 'allotTime',
    },
  },
  {
    title: '调拨人',
    ellipsis: true,
    dataIndex: 'createBy',
    width: 180,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'createBy',
    },
  },
  {
    title: '调拨单提交时间',
    ellipsis: true,
    dataIndex: 'createTime',
    width: 180,
    scopedSlots: {
      filterDropdown: 'datePicker2',
      filterIcon: 'dateIcon',
      customRender: 'createTime',
    },
  },

  {
    title: '审核状态',
    ellipsis: true,
    dataIndex: 'flowStatus',
    selectValue: 'value',
    selectText: 'text',
    width: 150,
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'selectIcon',
      customRender: 'flowStatus',
    },
  },
  {
    title: '调拨状态',
    ellipsis: true,
    dataIndex: 'orderStatus',
    width: 180,
    scopedSlots: {
      filterDropdown: 'selectDropdownAllot',
      filterIcon: 'selectIcon',
      customRender: 'orderStatus',
    },
  },
]
const actionArr = [
  {
    fixed: 'right',
    title: '操作',
    width: 110,
    align: 'left',
    dataIndex: 'actions',
    ellipsis: true,
    scopedSlots: { customRender: 'actions' },
  },
]
export default {
  mixins: [tableDragResize],
  name: 'warehouseList', //仓库管理列表
  data() {
    return {
      columnsValue,
      loginUser: '',
      submitApi: '',
      flowStatusList: [],
      allocationStatus: [
        {
          value: 'not_effective',
          text: '未生效',
        },
        {
          value: 'take_effect',
          text: '已生效',
        },
      ],
      statusList: [
        {
          value: 'no_effective',
          text: '未生效',
        },
        {
          value: 'effective',
          text: '已生效',
        },
      ],
      // 流程
      processDataVo: '',
      type: '0', //0是新增，1是编辑，2是详情
      id: 'WMS_WAREHOUSE', //此id用获取流程审批节点和获取详情中流程流转记录（注意：两者id并不相同）
      // 新建
      clickType: '',
      accloading: false,
      addDialog: false,
      newAddForm: {
        applyNumber: '',
        warehouseName: '',
        warehouseType: '',
      },
      addRules: {
        warehouseName: [{ required: true, message: '请输入', trigger: 'change' }],
        applyNumber: [
          { required: true, message: '请输入', trigger: 'change' },
          // {
          //   message: '该编号已存在',
          //   validator: (rule, value, callback) =>
          //     validateDuplicateValue('WMS_WAREHOUSE', 'apply_number', value, queryId, callback),
          // },
        ],
        warehouseType: [{ required: true, message: '请选择', trigger: 'change' }],
      },
      labelCol: { span: 4 },
      wrapperCol: { span: 17 },
      isEdit: false,
      dictOptions: '', //仓库分类字典下拉数据
      validateDuplicateValue, //自动生成编码
      warehouseList: [], //所有仓库
      //人员组件 提交人
      createStr: '',
      showCreateStr: '', //提交人
      moment,
      subStrText,
      selectedRowKeys: [],
      showFilter: false, // 筛选抽屉
      modelList: [], // 列表数据
      showSetColumn: false, // 显示
      // 排序
      sortForm: {
        sortType: '',
        sortColumn: '',
      },
      //全选按钮
      indeterminate: false,
      checkAll: false,
      current: 1,
      total: 0,
      pageSize: 10,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      columns: [
        {
          title: '调拨单号',
          ellipsis: true,
          dataIndex: 'allotOrder',
          width: 180,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'allotOrder',
          },
        },
        {
          title: '调出仓库',
          ellipsis: true,
          dataIndex: 'outWarehouseId',
          width: 180,
          scopedSlots: {
            filterDropdown: 'selectDropdown1',
            filterIcon: 'selectIcon',
            customRender: 'outWarehouseId',
          },
        },
        {
          title: '调入仓库',
          ellipsis: true,
          dataIndex: 'inWarehouseId',
          width: 150,
          scopedSlots: {
            filterDropdown: 'selectDropdown1',
            filterIcon: 'selectIcon',
            customRender: 'inWarehouseId',
          },
        },
        {
          title: '调拨合格品数',
          align: 'left',
          width: 150,
          ellipsis: true,
          dataIndex: 'qualifiedNum',
          scopedSlots: {
            // filterDropdown: 'selectDropdown1',
            // filterIcon: 'selectIcon',
            customRender: 'qualifiedNum',
          },
        },
        {
          title: '调拨报废品数',
          align: 'left',
          width: 150,
          ellipsis: true,
          dataIndex: 'scrapNum',
          scopedSlots: {
            // filterDropdown: 'selectDropdown1',
            // filterIcon: 'selectIcon',
            customRender: 'scrapNum',
          },
        },
        {
          title: '调拨合格品数(F)',
          align: 'left',
          width: 150,
          ellipsis: true,
          dataIndex: 'qualifiedNumTextAssistUnit',
        },
        {
          title: '调拨报废品数(F)',
          align: 'left',
          width: 150,
          ellipsis: true,
          dataIndex: 'scrapNumTextAssistUnit',
        },
        {
          title: '调拨物品编号',
          ellipsis: true,
          dataIndex: 'goodsCode',
          width: 150,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsCode',
          },
        },
        {
          title: '调拨物品名称',
          ellipsis: true,
          dataIndex: 'goodsName',
          width: 180,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsName',
          },
        },
        {
          title: '规格',
          ellipsis: true,
          dataIndex: 'spec',
          width: 180,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            // customRender: 'spec',
          },
        },
        {
          title: '调拨日期',
          ellipsis: true,
          dataIndex: 'allotTime',
          width: 180,
          scopedSlots: {
            filterDropdown: 'datePicker',
            filterIcon: 'dateIcon',
            customRender: 'allotTime',
          },
        },
        {
          title: '调拨人',
          ellipsis: true,
          dataIndex: 'createBy',
          width: 180,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'createBy',
          },
        },
        {
          title: '调拨单提交时间',
          ellipsis: true,
          dataIndex: 'createTime',
          width: 180,
          scopedSlots: {
            filterDropdown: 'datePicker2',
            filterIcon: 'dateIcon',
            customRender: 'createTime',
          },
        },
        {
          title: '审核状态',
          ellipsis: true,
          dataIndex: 'flowStatus',
          width: 180,
          scopedSlots: {
            filterDropdown: 'selectDropdown',
            filterIcon: 'selectIcon',
            customRender: 'flowStatus',
          },
        },

        {
          title: '调拨状态',
          ellipsis: true,
          dataIndex: 'orderStatus',
          width: 180,
          scopedSlots: {
            filterDropdown: 'selectDropdownAllot',
            filterIcon: 'selectIcon',
            customRender: 'orderStatus',
          },
        },
        // {
        //   fixed: 'right',
        //   title: '操作',
        //   width: 110,
        //   align: 'left',
        //   dataIndex: 'actions',
        //   ellipsis: true,
        //   scopedSlots: { customRender: 'actions' },
        // },
      ],
      filterForm: {
        allotOrder: '', //调拨单号
        outWarehouseId: undefined,
        inWarehouseId: undefined,
        qualifiedNum: '',
        scrapNum: '',
        goodsCode: '',
        goodsName: '',
        spec: '',
        allotTime: null,
        createBy: '',
        createTime: '',
        allotBeginTime: null,
        allotEndTime: null,
        submitBeginTime: null,
        submitEndTime: null,
        // applyNumber: '', //仓库编号
        // warehouseName: '', //仓库名称
        // warehouseType: undefined, //分类
        flowStatus: undefined, //审核状态
        orderStatus: undefined,
        // status: undefined, //仓库状态
      },
      filteredFormLable: {
        allotOrder: '调拨单号',
        outWarehouseId: '调出仓库',
        inWarehouseId: '调入仓库',
        qualifiedNum: '调拨合格品数',
        scrapNum: '调拨报废品数',
        goodsCode: '调拨物品编号',
        goodsName: '调拨物品名称',
        spec: '规格',
        allotTime: '调拨日期',
        createBy: '调拨人',
        createTime: '调拨单提交日期',
        flowStatus: '审核状态', //审核状态
        orderStatus: '调拨状态',
        // applyNumber: '仓库编号',
        // warehouseName: '仓库名称',
        // warehouseType: '分类', //分类
        // flowStatus: '审核状态', //审核状态
        // status: '仓库状态', //仓库状态
      },
      flowStatus: {
        RUNNING: { text: '审批中', color: '#FF943E' },
        REFUSE: { text: '已拒绝', color: '#FF4D4F' },
        CANCELED: { text: '已撤回', color: '#888888' },
        AGREE: { text: '已通过', color: '#00B042' },
        TERMINATED: { text: '已终止', color: '#FF4D4F' },
      },
      orderStatus: {
        take_effect: { text: '已生效', color: '#FF943E' },
        not_effect: { text: '未生效', color: '#FF4D4F' },
      },
      userNames: '',
      dateForm: {},
      tableKey: 1.9,
    }
  },
  components: {
    SetColumn,
    crumbs,
    Examine,
    windowForm: (resolve) => require(['@/views/warehouseManagement/stockAllocation/stockAllocationAdd'], resolve),
    windowDetail: (resolve) => require(['@/views/warehouseManagement/stockAllocation/stockAllocationDetail'], resolve),
  },
  computed: {
    scrollX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width) || 0
      }
      return xnum
    },
    ...mapState({
      collapsed: (state) => state.user.collapsed,
    }),

    filteredList() {
      let list = []
      for (let key in this.filterForm) {
        if (key == 'allotTime') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm.allotBeginTime
              ? moment(this.filterForm.allotBeginTime).format('YYYY-MM-DD') +
                '-' +
                moment(this.filterForm.allotEndTime).format('YYYY-MM-DD')
              : '',
            key,
          })
        } else if (key == 'createTime') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm.submitBeginTime
              ? moment(this.filterForm.submitBeginTime).format('YYYY-MM-DD') +
                '-' +
                moment(this.filterForm.submitEndTime).format('YYYY-MM-DD')
              : '',
            key,
          })
        } else if (this.filterForm[key] !== undefined && this.filteredFormLable[key] == '调出仓库') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.statusToTxt(key, this.filterForm[key]),
            key,
          })
        } else if (this.filterForm[key] !== undefined && this.filteredFormLable[key] == '调入仓库') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.statusToTxt(key, this.filterForm[key]),
            key,
          })
        } else if (this.filterForm[key] !== undefined && this.filteredFormLable[key] == '审核状态') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.statusToTxt(key, this.filterForm[key]),
            key,
          })
        } else if (this.filterForm[key] !== undefined && this.filteredFormLable[key] == '分类') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.statusToTxt(key, this.filterForm[key]),
            key,
          })
        } else if (this.filteredFormLable[key] == '调拨状态') {
          console.log(key, this.filteredFormLable[key], '---filteredList---key')
          list.push({
            title: this.filteredFormLable[key],
            text: this.statusToTxt(key, this.filterForm[key]),
            key,
          })
        } else if (key == 'allotBeginTime' || key == 'allotEndTime') {
          // 什么都不干
        } else if (key == 'submitBeginTime' || key == 'submitEndTime') {
          // 什么都不干
        } else if (this.filterForm[key] !== undefined && this.filteredFormLable[key] == '仓库状态') {
          let param = []
          this.filterForm[key].forEach((item) => {
            if (item == 'no_effective') {
              param.push('未生效')
            } else if (item == 'effective') {
              param.push('已生效')
            }
          })
          list.push({
            title: this.filteredFormLable[key],
            text: param.join(','),
            key,
          })
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      return list
    },
    filteredNums(n) {
      let nums = 0
      console.log(this.filterForm, '---filteredNums')
      if (n) {
        for (let key in this.filterForm) {
          if (
            this.filterForm[key] != '' &&
            key != 'createBy' &&
            this.filterForm[key] != null &&
            this.filterForm[key] != undefined
          ) {
            nums += 1
            if (key == 'allotBeginTime') {
              nums -= 1
            }
            if (key == 'submitBeginTime') {
              nums -= 1
            }
          }
        }
      } else {
        for (let key in this.filterForm) {
          if (this.filterForm[key] != '' && this.filterForm[key] != null && this.filterForm[key] != undefined) {
            nums += 1
            if (key == 'allotBeginTime') {
              nums -= 1
            }
            if (key == 'submitBeginTime') {
              nums -= 1
            }
          }
        }
      }
      return nums
    },
  },
  created() {
    let user = localStorage.getItem('pro__Login_Userinfo')
    this.loginUser = JSON.parse(user).value.realname
    this.initData()
    this.requestData()
  },
  mounted() {
    console.log('filteredNums:', this.filteredNums)
  },
  methods: {
    typeSelectChange() {
      //校验一下仓库分类
      this.$refs['addForm'].validateField(['warehouseType'])
    },
    subFlowStatusText(e) {
      if (e) {
        return this.flowStatus[e].text || ''
      }
    },
    // 点击 新增||编辑 仓库
    /* actionAcconut(type, item) {
      this.clickType = type
      this.submitApi = APILX.wmsWarehouseAdd
      if (type == 'edit') {
        this.submitApi = APILX.wmsWarehouseEdit
        console.log(item, 'item')
        for (let i in this.newAddForm) {
          this.newAddForm[i] = item[i]
        }
        this.newAddForm.id = item.id
      } else {
        this.newAddForm = {
          applyNumber: '',
          warehouseName: '',
          warehouseType: '',
        }
      }
      this.addDialog = true
    }, */
    // 点击 modal的取消按钮
    /* cancelAdd() {
      this.addDialog = false
      this.$refs['addForm'].resetFields()
    }, */
    /* submitProcess(e) {
      if (this.clickType == 'edit') {
        this.saveAcction()
      } else {
        console.log(e, 'eeee')
        if (e.nodeDtos) {
          this.processDataVo = e
          console.log(e, this.processDataVo, 'processDataVo')
          // 获取到数据后写表单提交的方法
          this.saveAcction(e)
        } else {
          // 调用子组件的方法获取数据
          this.$refs.examine.confirm()
        }
      }
    }, */
    //点击 新增||编辑仓库 的保存按钮
    /* saveAcction(processDataVo) {
      // debugger
      // console.log(formName, 'formName')
      this.$refs.addForm.validate((valid) => {
        // this.$refs[formName].validate((valid) => {
        console.log(valid, 'valid')
        if (valid) {
          this.accloading = true
          let param = this.newAddForm
          param.processDataVo = processDataVo
          console.log('param', param)
          this.submitApi(param)
            .then((res) => {
              if (res.code == 200) {
                this.$antdMessage.success(res.message)
                this.accloading = false
                this.cancelAdd()
                this.requestData()
              } else {
                this.$antdMessage.error(res.message)
                this.accloading = false
                this.cancelAdd()
              }
            })
            .finally(() => {
              this.accloading = false
              this.cancelAdd()
            })
        }
      })
    }, */
    /* 进度条颜色 */
    /*  checkStatus(value) {
      if (value == 0) {
        return '#DFDFDF'
      } else if (value >= 100) {
        return '#4bd863'
      } else {
        return '#1890ff'
      }
    }, */
    /* handleDetailOrder(v) {
      this.$router.push({
        path: '/workOrderDetail',
        query: { id: v.orderId },
      })
    }, */
    /* handleApplyReceipt(url) {
      this.$router.push({
        path: url,
      })
    }, */

    /* 初始/加载设置列 */
    initData() {
      var oldValue = localStorage.getItem(this.BUSI_CONST.Entity.STOCKALLOCATION_LIST)
      this.columns = getNewColumns(this.columnsValue, JSON.parse(oldValue), actionArr, this.columns)
      getEnableOne({ id: 'WMS_STOCK_ALLOT', type: 'add' }).then((res) => {
        if (res.result && res.result == 'false') {
          this.columnsValue = this.columnsValue.filter((item) => item.title != '审核状态')
          this.columns = this.columns.filter((item) => item.title != '审核状态')
        }
      })
      APILX.wmsWarehouseGetTypeList().then((res) => {
        if (res.code == 200) {
          this.dictOptions = res.result
        }
      })
      stockAllocQueryWarehouse().then((res) => {
        if (res.success) {
          this.warehouseList = res.result.records
          console.log(this.warehouseList, '---stockAllocQueryWarehouse')
          // this.stockLIst = res.result
        } else {
          this.$antdMessage.warning(res.message)
        }
      })
      // 类型字典
      let parameters = { dictCode: 'erp_apply_status' }
      getDictModel(parameters).then((res) => {
        if (res.code == 200) {
          console.log(res, 'erp_apply_status')
          this.flowStatusList = res.result
        }
      })
    },
    /* 筛选状态回显文字 */
    statusToTxt(key, val) {
      console.log(key, val, '---statusToTxt')
      var valList = []
      if (key == 'outWarehouseId' && this.filterForm[key]) {
        for (let i = 0; i < val.length; i++) {
          const item = val[i]
          for (let j = 0; j < this.warehouseList.length; j++) {
            const txt = this.warehouseList[j]
            if (item === txt.id) {
              valList.push(txt.warehouseName)
            }
          }
        }
        return valList.join(',')
      }
      if (key == 'inWarehouseId' && this.filterForm[key]) {
        for (let i = 0; i < val.length; i++) {
          const item = val[i]
          for (let j = 0; j < this.warehouseList.length; j++) {
            const txt = this.warehouseList[j]
            if (item === txt.id) {
              valList.push(txt.warehouseName)
            }
          }
        }
        return valList.join(',')
      }
      if (key == 'orderStatus' && this.filterForm[key]) {
        for (let i = 0; i < val.length; i++) {
          const item = val[i]
          for (let j = 0; j < this.allocationStatus.length; j++) {
            const txt = this.allocationStatus[j]
            if (item === txt.value) {
              valList.push(txt.text)
            }
          }
        }
        return valList.join(',')
      }
      if (key == 'warehouseType' && this.filterForm[key]) {
        for (let i = 0; i < val.length; i++) {
          const item = val[i]
          for (let j = 0; j < this.dictOptions.length; j++) {
            const txt = this.dictOptions[j]
            if (item == txt.value) {
              valList.push(txt.text)
            }
          }
        }
        return valList.join(',')
      } else if (key == 'flowStatus' && this.filterForm[key]) {
        for (let i = 0; i < val.length; i++) {
          const item = val[i]
          for (let j = 0; j < this.flowStatusList.length; j++) {
            const txt = this.flowStatusList[j]
            if (item == txt.value) {
              valList.push(txt.text)
            }
          }
        }
        return valList.join(',')
      } else if (key == 'status' && this.filterForm[key]) {
        for (let i = 0; i < val.length; i++) {
          const item = val[i]
          for (let j = 0; j < this.statusList.length; j++) {
            const txt = this.statusList[j]
            if (item == txt.value) {
              valList.push(txt.text)
            }
          }
        }
        return valList.join(',')
      }
    },
    selectkeys(key) {
      console.log(key, '---selectkeys')
      if (key == 'customerIdText') {
        return 'customerId'
      } else if (key == 'flowStatus') {
        return 'flowStatus'
      } else if (key == 'status') {
        return 'status'
      } else if (key == 'orderStatus') {
        return 'orderStatus'
      }
    },
    selectOptions(key) {
      console.log(key, 'options,key')
      if (key == 'warehouseType') {
        return this.dictOptions
      } else if (key == 'flowStatusText') {
        return this.applyStatusList
      } else if (key == 'status') {
        return this.statusList
      } else if (key == 'flowStatus') {
        console.log(this.flowStatusList, '---flowStatusList')
        return this.flowStatusList
      }
    },
    checkInputValue(value) {
      validateDuplicateValue('WMS_WAREHOUSE', 'apply_number', value, '', (res) => {
        if (res) {
          this.newAddForm.applyNumber = ''
          this.$antdMessage.warning(res)
        }
      })
    },
    /* 自动生成 */
    genEntityCode() {
      API.genEntityCode({ entityCode: 'WMS_WAREHOUSE' }).then((res) => {
        if (res.code == 200) {
          this.newAddForm.applyNumber = res.result
          this.$refs['addForm'].validateField(['applyNumber'])
        } else {
          this.newAddForm.applyNumber = ''
          this.$refs['addForm'].validateField(['applyNumber'])
          this.$antdMessage.error(res.message)
        }
      })
    },
    /* 请求列表数据 */
    requestData() {
      console.log(this.filterForm, '---this.filterForm')
      let warehouseType = undefined
      if (this.filterForm.warehouseType && this.filterForm.warehouseType.length > 0) {
        warehouseType = this.filterForm.warehouseType.join(',')
      }
      let status = undefined
      if (this.filterForm.status && this.filterForm.status.length > 0) {
        status = this.filterForm.status.join(',')
      }
      let flowStatus = undefined
      if (this.filterForm.flowStatus && this.filterForm.flowStatus.length > 0) {
        flowStatus = this.filterForm.flowStatus.join(',')
      }
      let tempoutWarehouseId = undefined
      if (this.filterForm.outWarehouseId) {
        tempoutWarehouseId = this.filterForm.outWarehouseId.join(',')
      }
      let tempintWarehouseId = undefined
      if (this.filterForm.inWarehouseId) {
        tempintWarehouseId = this.filterForm.inWarehouseId.join(',')
      }
      let tempOrderStatus = undefined
      if (this.filterForm.orderStatus) {
        tempOrderStatus = this.filterForm.orderStatus.join(',')
      }

      /*  if (this.filterForm.planStartTime && this.filterForm.planStartTime.length > 0) {
        startDate = this.filterForm.planStartTime[0]
        endDate = this.filterForm.planStartTime[1]
      } else {
        startDate = ''
        endDate = ''
      }
      let allocationTime = null;
      let allocationOrderSubTime = null;
       if (this.filterForm.planStartTime && this.filterForm.planStartTime.length > 0) {
         allocationTime = JSON.stringify(this.filterForm.planStartTime)

      } else {
        startDate = ''
        endDate = ''
      } */
      let parameter = {
        warehouseType: warehouseType,
        applyNumber: this.filterForm.applyNumber, //仓库编号
        warehouseName: this.filterForm.warehouseName, //仓库名称
        // outWarehouseId: this.filterForm.outWarehouseId, //调出仓库
        outWarehouseId: tempoutWarehouseId,
        inWarehouseId: tempintWarehouseId, //调入仓库
        goodsCode: this.filterForm.goodsCode, //调拨物品编号
        goodsName: this.filterForm.goodsName, //调拨物品名称
        spec: this.filterForm.spec, //规格
        createBy: this.filterForm.createBy,
        // allotTime: JSON.stringify(this.filterForm.planStartTime),
        allotBeginTime: this.filterForm.allotBeginTime,
        allotEndTime: this.filterForm.allotEndTime,
        // createTime: JSON.stringify(this.filterForm.planStartTime2),
        submitBeginTime: this.filterForm.submitBeginTime,
        submitEndTime: this.filterForm.submitEndTime,
        flowStatus: flowStatus, //审核状态
        status: status, //仓库状态
        orderStatus: tempOrderStatus,
        allotOrder: this.filterForm.allotOrder,

        pageNo: this.current,
        pageSize: this.pageSize,
        // ...this.filterForm,
        // ...this.sortForm,
      }
      console.log(parameter, 'parameter')
      /* APILX.wmsWarehouseList(parameter).then((res) => {
        console.log(res, 'wmsWarehouseList---wmsWarehouseList')
        if (res.code == 200) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          this.modelList = res.result.records
          // this.modelList.forEach(record => {
          // })
        }
      }) */
      stockAllocationListApi(parameter).then((res) => {
        console.log(res, '---stockAllocationListApi')
        if (res.code == 200) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          this.modelList = res.result.records
        }
      })
    },
    /* 打开设置列面板 */
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(this.columnsValue, this.BUSI_CONST.Entity.STOCKALLOCATION_LIST, this.columns)
      })
    },
    /* 设置列 */
    sureBtn(emitArr) {
      this.columns = getNewColumns(this.columnsValue, emitArr, actionArr)
      console.log(this.columns, '---sureBtn')
      localStorage.setItem(this.BUSI_CONST.Entity.STOCKALLOCATION_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    /* 详情 */
    handleDetail(v) {
      this.$refs.windowDetail.initDetail(v.id)
    },
    /* 删除 */
    /* handleDelete(v) {
      let that = this
      that.$antdConfirm({
        title: '删除后不可恢复',
        content: `确定删除吗？`,
        onOk() {
          APILX.wmsWarehouseDelete(v.id).then((res) => {
            if (res.code == 200) {
              that.$antdMessage.success('仓库删除成功！')
              that.requestData()
            } else {
              that.$antdMessage.error(res.message)
            }
          })
        },
        onCancel() {},
      })
    }, */
    /* 撤回 */
    handleWithdraw(v) {
      console.log(v, '---handleWithdraw')
      let that = this
      that.$antdConfirm({
        title: '撤回申请将被拒绝',
        content: `确定撤回吗？`,
        onOk() {
          APILX.operateRevoke({ flowInstId: v.flowInstId }).then((res) => {
            if (res.code == 200) {
              that.$antdMessage.success('撤回成功！')
              that.handleSearch()
            } else {
              that.$antdMessage.error(res.message)
            }
          })
        },
        onCancel() {},
      })
    },
    /* 汇报时间选择 */
    onOk(value, key) {
      if (value.length == 0) {
        this.filterForm[`allotBeginTime`] = ''
        this.filterForm[`allotEndTime`] = ''
        this.filterForm[key] = ''
        return
      }
      this.filterForm[`allotBeginTime`] = moment(value[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
      this.filterForm[`allotEndTime`] = moment(value[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
      console.log(this.filterForm, this.filteredFormLable, '---onOk')
    },
    /* 创建时间选择 */
    onOkCreate(value, key) {
      if (value.length == 0) {
        this.filterForm[`submitBeginTime`] = ''
        this.filterForm[`submitEndTime`] = ''
        this.filterForm[key] = ''
        return
      }
      this.filterForm[`submitBeginTime`] = moment(value[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
      this.filterForm[`submitEndTime`] = moment(value[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
    },
    // 排序
    handleChange(pagination, filters, sorter, { currentDataSource }) {
      console.log('看看这是啥33：', sorter)
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        this.sortForm = {
          sortType: sortType,
          sortColumn: camelCase2UnderLine(sorter.columnKey),
        }
        this.requestData()
      } else {
        this.sortForm = {
          sortType: '',
          sortColumn: '',
        }
        this.requestData()
      }
    },
    setColor(s) {
      let cor = {
        1: '#888888',
        2: '#1890FF',
        3: '#00B042',
      }
      return cor[s] || ''
    },
    /* checkColor(value) {
      if (value == 0) {
        return '#DFDFDF'
      } else if (value >= 100) {
        return '#00B042'
      } else {
        return '#1890FF'
      }
    }, */
    // 列头检索提示语
    checkPlaceholder(dataIndex) {
      // console.log(dataIndex, 'dataIndex')
      let str = ''
      switch (dataIndex) {
        case 'applyNumber':
          str = '请输入仓库编号'
          break
        case 'warehouseName':
          str = '请输入仓库名称'
          break
        case 'warehouseType':
          str = '请选择分类'
          break
        case 'applyTime':
          str = '请选择时间'
          break
        case 'applicantId':
          str = '请选择提交人'
          break
      }
      return str
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData()
    },
    onShowSizeChange(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData()
    },
    handleSearch(selectedKeys, confirm, dataIndex, clearFilters) {
      // confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      console.log('这都是啥00：', selectedKeys)
      console.log('这都是啥11：', confirm)
      console.log('这都是啥22：', dataIndex)
      console.log('这都是啥33：', clearFilters)
      this.current = 1
      this.requestData()
    },
    /* 打开筛选 */
    handleShowFilter() {
      this.showFilter = true
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    /* 确定筛选 */
    handleFilter() {
      this.handleSearch()
      this.showFilter = false
    },
    /* 删除已选 */
    delFiltered(key) {
      if (this.filteredFormLable[key] == '提交人') {
        this.createStr = ''
        this.showCreateStr = ''
        this.filterForm[key] = ''
      } else if (this.filteredFormLable[key] == '分类') {
        this.filterForm[key] = undefined
      } else if (key == 'allotTime') {
        this.filterForm.allotBeginTime = ''
        this.filterForm.allotEndTime = ''
        this.filterForm[key] = ''
        this.dateForm[key] = null
      } else if (key == 'createTime') {
        this.filterForm.submitBeginTime = ''
        this.filterForm.submitEndTime = ''
        this.filterForm[key] = ''
        this.dateForm[key] = null
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        spec: '',
        applyNumber: '', //仓库编号
        warehouseName: '', //仓库名称
        warehouseType: undefined,
        flowStatus: undefined, //审核状态
        status: undefined, //仓库状态
      }
      this.dateForm = {}
      // this.showFilter = false
      this.handleSearch()
    },
    // 日期选择
    /*  rangePickChang(a, b) {
      console.log(a, b, '---rangePickChang')
      //   let planStartTime = null
      //   if (!b[0] && !b[1]) {
      //     planStartTime = []
      //   } else {
      //     planStartTime = b
      //   }
      //   this.$set(this.filterForm, 'planStartTime', planStartTime)
    }, */
    /*  rangePickChang2(a, b) {
      let planStartTime = null
      if (!b[0] && !b[1]) {
        planStartTime = []
      } else {
        planStartTime = b
      }
      this.$set(this.filterForm, 'planStartTime2', planStartTime)
    }, */
    // 抽屉方法
    /* startTimeChange(a, b) {
      let planStartTime = null
      if (!b[0] && !b[1]) {
        planStartTime = []
      } else {
        planStartTime = b
      }
      this.$set(this.filterForm, 'planStartTime', planStartTime)
    }, */
    /* startTimeChange2(a, b) {
      let planStartTime = null
      if (!b[0] && !b[1]) {
        planStartTime = []
      } else {
        planStartTime = b
      }
      this.$set(this.filterForm, 'planStartTime2', planStartTime)
    }, */
    //点击返回按钮
    goBack() {
      console.log('goback')
    },
    // 新建
    add() {
      this.$refs.windowForm.initForm()
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.header {
  width: 150%;
  margin: -12px -12px @distance4;
}
.backBox {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .backC {
    cursor: pointer;
    display: flex;
    align-items: center;
  }
}
.j-table-force-nowrap {
  margin-top: @distance1;
}
.btns {
  margin-left: @distance5;
}
.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}
.mg-left {
  margin-left: @distance3;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap:nth-of-type(n + 2) {
  margin-top: 10px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
/deep/ .ant-card-body {
  height: calc(100vh - 214px);
  overflow: hidden;
  padding: 20px 16px;
}
.code-btn {
  position: absolute;
  right: 10px;
  top: -11.5px;
}
body {
  overflow: hidden !important;
}
</style>
